﻿using Microsoft.EntityFrameworkCore;

namespace _20EFCore乐观并发控制;

public class MyDbContext:DbContext
{
    public DbSet<House> Houses { get; set; }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        base.OnConfiguring(optionsBuilder);
        var connectionString = "Server=.;Database=efCorePractice_2;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=true;";
        optionsBuilder.UseSqlServer(connectionString);
        optionsBuilder.LogTo(message => Console.WriteLine(message));
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
        modelBuilder.ApplyConfigurationsFromAssembly(GetType().Assembly);
    }
}